# -*- coding: utf-8 -*-
# @Time : 2022/1/14 10:46
# @Author : Limusen
# @File : demo_connect_01


from appium import webdriver

des = {
    "platformName": "Android",
    "platformVersion": "9.0",
    "deviceName": "Samsung Galaxy S9",
    "appPackage": "com.android.calculator2",
    "appActivity": "com.android.calculator2.Calculator",
    "udid": "192.168.0.101:5555",
    "noReset": "True",
    "unicodeKeyboard": "True",
    "resetKeyboard": "True"
}

driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', des)

driver.find_element_by_xpath(
    '//android.widget.FrameLayout/android.widget.FrameLayout'
    '/android.widget.FrameLayout/android.view.ViewGroup'
    '/android.widget.LinearLayout/android.widget.LinearLayout[2]'
    '/android.view.ViewGroup[1]/android.widget.Button[2]').click()


# 使用text属性定位  '//属性值[@text=""]'
driver.find_element_by_xpath('//android.widget.Button[@text="+"]').click()  # 点击＋号
# 使用resource-id  '//属性值[@resource-id=""]'
driver.find_element_by_xpath('//android.widget.Button[@resource-id="com.android.calculator2:id/digit_6"]').click()  # 点击6
# 使用bounds
driver.find_element_by_xpath('//android.widget.Button[@bounds="[1184,2482][1412,2764]"]').click()  # 点击=